﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ContactList.ascx.cs" Inherits="admin_webparts_Plug_ins_Contact_ContactList" %>
<%@ Import Namespace="NTTHAO.CommonWeb" %>
<%@ Import Namespace="NTTHAO.Web.BL.Contact" %>
<div class="tip">
    <h1 style="left: 0px; position: relative;"><%=_Group == null ? "" : _Group.Name %></h1>
    <div style="display: block; width: 32px; height: 32px; float: right; position: relative; top: -27px;"><a title="<%=LanguageUtility.GetLanguageText("CLICK_RETURN", Session) %>" href="?type=<%=Request.QueryString["type"] %>&name=<%=Request.QueryString["name"] %>"><img src="resources/images/Back.png" alt="" /></a></div>
</div>
<div style="border: solid 1px #89F;padding: 5px;margin-bottom: 10px;">
    <div style="overflow: hidden;font-weight: bold; padding-left: 2px;">
        <span><%=LanguageUtility.GetLanguageText("TOTAL") %>: <span style="color: #E76300;"><%=_TotalItem %></span> <%=LanguageUtility.GetLanguageText("ITEMS") %>.</span> <%if (_TotalItem > 1) { %>
        <span><%=LanguageUtility.GetLanguageText("VIEW")%>: <span style="color: #E76300;"><%=(_PageNo - 1) * PAGE_SIZE + 1%> - <%= ((_PageNo - 1) * PAGE_SIZE + (_List == null ? 0 : _List.Rows.Count))%></span></span>
        <%} %>
    </div>
<%if (_PageCount > 1) { %>
    <div style="overflow: hidden; padding-top: 10px;">
        <div class="boxPaging">
            <div class="pagenum f-left">
                <ul>
                    <li><a class="first" href="<%=this._PageUrl + "page=1" %>">|&lt;&nbsp;Đầu</a></li>
                    <li><a class="pre" href="<%=this._PageUrl + "page=" + (this._PageNo <= 1 ? 1 : (this._PageNo - 1)) %>">&lt;</a></li>
                    <%
                        int startPage = _PageNo - 4;
                        if (startPage > _PageCount - 9)
                        {
                            startPage = _PageCount - 9;
                        }
                        if (startPage < 1)
                        {
                            startPage = 1;
                        }
                        for (int i = startPage; i <= _PageCount && i < (startPage + 10); i++)
                        {
                    %>
                    <li <%=(i == _PageNo ? "class=\"selected\"" : "") %>><a href="<%=this._PageUrl + "page=" + i.ToString() %>"><%=i %></a></li>
                    <%   
                        }
                    %>
                    <li><a class="next" href="<%=this._PageUrl + "page=" + (this._PageNo >= this._PageCount ? this._PageCount : (this._PageNo + 1)) %>">&gt;</a></li>
                    <li><a class="last" href="<%=this._PageUrl + "page=" + this._PageCount.ToString() %>">Cuối&nbsp;&gt;|</a></li>
                </ul>
            </div>
        </div>
    </div>
<%} %>
</div>
<%
int startNum = (_PageNo - 1) * PAGE_SIZE;
 %>
<table border="1" cellpadding="0" cellspacing="0" class="grid" id="tbGrid" style="margin-top: 10px;">
    <tr>
        <th width="20px">#</th>
        <th><%=LanguageUtility.GetLanguageText("CONTENT", Session)%></th>
        <th><%=LanguageUtility.GetLanguageText("INSERT_DATE", Session)%></th>
<%if(Context.User.Identity.Name.Equals("admin", StringComparison.OrdinalIgnoreCase)) { %>
        <th>IP Address</th>
<%} %>
    </tr>
<%
if (this._List != null)
{
    for (int i = 0; i < this._List.Rows.Count; i++)
    {
        System.Data.DataRow row = this._List.Rows[i];
        string id = row[ContactDetail.ID__COLUMN_NAME].ToString();
        string name = row[ContactDetail.NAME__COLUMN_NAME].ToString();
        string time = ((DateTime)row[ContactDetail.INSERTDATE__COLUMN_NAME]).ToString("yyyy/MM/dd HH:mm");
        string ip = row[ContactDetail.CONTACTIPADDRESS__COLUMN_NAME].ToString();
%>
    <tr class="<%=(i%2==1?"even":"odd") %>">
        <td align="center"><%=i + 1 + startNum %></td>
        <td><a href="?type=<%=Request.QueryString["type"] %>&name=<%=Request.QueryString["name"] %>&action=viewcontact&gid=<%=Request.QueryString["id"] %>&id=<%=id %>"><%=name %></a></td>
        <td align="center"><%=time%></td>
<%if(Context.User.Identity.Name.Equals("admin", StringComparison.OrdinalIgnoreCase)) { %>
        <td align="center"><%=ip %></td>
<%} %>
    </tr>
<%
    }
} %>
</table>